package com.xinruke.hostels.systemmanage.controller;

import com.xinruke.hostels.central.manage.interfaces.dto.*;
import com.xinruke.hostels.common.controller.BaseController;
import com.xinruke.hostels.common.vo.ResultVO;
import com.xinruke.hostels.common.vo.query.RowsDataVO;
import com.xinruke.hostels.systemmanage.service.BuildingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 楼栋管理
 *
 * @author Jinz
 * @date 2019-06-26 23:43
 */
@RestController
@RequestMapping("/building")
@Api(tags = "楼栋")
public class BuildingController extends BaseController {
    @Autowired
    private BuildingService buildingService;

    @PostMapping("/add")
    @ApiOperation("添加楼栋")
    public ResultVO add(@Valid @RequestBody BuildingAddQueryDTO buildingAddQueryDTO) {
        return buildingService.add(buildingAddQueryDTO);
    }

    @PostMapping("/modify")
    @ApiOperation("修改楼栋")
    public ResultVO modify(@Valid @RequestBody BuildingUpdateQueryDTO buildingUpdateQueryDTO) {
        return buildingService.modify(buildingUpdateQueryDTO);
    }

    @PostMapping("/del")
    @ApiOperation("删除楼栋")
    public ResultVO delete(@Valid @RequestBody BuildingDelQueryDTO buildingDelQueryDTO) {
        return buildingService.delete(buildingDelQueryDTO);
    }

    @PostMapping("/detail")
    @ApiOperation("楼栋详情")
    public ResultVO<BuildingDetailQueryResultDTO> detail(@Valid @RequestBody BuildingDetailQueryDTO buildingDetailQueryDTO) {
        return buildingService.detail(buildingDetailQueryDTO);
    }

    @PostMapping("/buildings")
    @ApiOperation("楼栋列表")
    public ResultVO<RowsDataVO<BuildingDetailQueryResultDTO>> buildings(@Valid @RequestBody BuildingsQueryDTO buildingsQueryDTO) {
        return buildingService.buildings(buildingsQueryDTO);
    }
}
